﻿<cfsilent>
	<cfscript>
		
		event.setArg("pageTitle", "教学运行基础数据 - 培养方案修订 - 添加学位课程");
		 
		sql = "SELECT a.sbj_name,a.sbj_id 
				FROM t_subject a 
				WHERE a.sbj_id = :SubID ";
		queryObj = new Query( datasource=application.dnsSlave ) ;
   		queryObj.addParam( name="SubID", value=event.getArg("SubID"), cfsqltype="cf_sql_varchar" );
		rs_subject = queryObj.execute( sql=sql ).getResult();
		
		targetArgs = structNew();
		structInsert(targetArgs, "SubID", event.getArg("SubID"), true);
		structInsert(targetArgs, "Edition", event.getArg("Edition"), true);
		structInsert(targetArgs, "Schema", event.getArg("Schema"), true);
		
		passArgs = structNew();
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('programSchema')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">培养方案</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 edit"></i>培养方案修订 - <cfoutput>#rs_subject.sbj_name#</cfoutput>专业(<cfoutput>#event.getArg("Edition")#</cfoutput>)版
				</h2>
			</div>
		</div>
	</div>
</div>

<!--- 加载导航菜单 --->
<!-- stepMenu-->
<cfoutput>#event.getArg("stepMenu")#</cfoutput>
<!--/stepMenu-->

<div class="UIElement">
	
	<ul class="accountSearch">
		<li>
			<div class="clearfix">
				<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('programSchemaWizardCreateAssistDegreeEntity', targetArgs)#</cfoutput>">
					<div class="label">
						<b>课程名称</b>
						<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
					</div>
					<hr/>
					<div class="lable">
						<input class="button1" type="submit" value="搜索课程" />
					</div>
				</form>
			</div>
		</li>
	</ul>
	
	<cfif event.isArgDefined('Keywords') AND len(event.getArg('Keywords'))>
		 
		<cfset sql = "SELECT 
							a.shm_id, c.course_name,
							c.course_credit, c.period, 
							c.period_theory, c.period_practice, 			
							c.period_computer, c.period_week, 
							d.institute_short,b.sbj_short, 
							b.sbj_id 
						FROM   t_schema a 
							   INNER JOIN t_subject b ON a.sbj_id = b.sbj_id 
							   INNER JOIN t_course c ON a.cid = c.cid 
							   INNER JOIN t_institute d ON c.institute_id = d.institute_id 
						WHERE 
							(
								c.course_name LIKE :keyword 
								OR
								c.course_code LIKE :keyword 
							)
							AND 
							a.grade = :grade 
							AND 
							(
								b.sbj_id LIKE :subjectId 
								OR
								b.sbj_id LIKE :subjectDir 
							)
						ORDER BY c.course_name ASC" />
                        
        <cfset queryObj = new Query( datasource=application.dnsSlave,maxRows=30 ) />
		<cfset queryObj.addParam( name="keyword", value=event.getArg('Keywords')&'%', cfsqltype="cf_sql_varchar" )/>
        <cfset queryObj.addParam( name="grade", value=event.getArg("Edition"), cfsqltype="cf_sql_char" )/>
        <cfset queryObj.addParam( name="subjectId", value=rs_subject.sbj_id, cfsqltype="cf_sql_varchar" )/>
        <cfset queryObj.addParam( name="subjectDir", value=rs_subject.sbj_id & "_", cfsqltype="cf_sql_varchar" )/>
        
        <cfset rs_courses = queryObj.execute( sql=sql ).getResult()/> 
           
		<cfif rs_courses.recordCount>
			
			<ul class="senateFirstPage">
				<li>
					<div class="clearfix" id="summary">
						
						<div id="searchProcess" class="tabContentBox hidden_elem">
							<form id="formCreate" onSubmit="javascript:return processVerfiyForm('formCreate');" class="formWrapper " method="post" action="<cfoutput>#buildURL('programSchemaWizardAssistDegreeEntityCreateDo')#</cfoutput>">

								<input name="Grade" id="Grade" type="hidden" value="<cfoutput>#event.getArg('Edition')#</cfoutput>" />
								<input name="SubjectID" id="SubjectID" type="hidden" value="<cfoutput>#event.getArg('SubID')#</cfoutput>" />
							
								<input name="SchemaID" id="SchemaID" type="hidden" value="" />
								
								<div class="label">
									<b>专业方向</b>
									<input name="SubjectName" id="SubjectName" type="text" class="typeTextReadOnly" verification="required" maxlength="30" value="" />
								</div>
								
								<hr/>
								
								<div class="label">
									<b>课程</b>
									<input name="CourseName" id="CourseName" type="text" class="typeTextReadOnly" verification="required" maxlength="30" value="" />
								</div>

								<div class="label">
									<b>学分</b>
									<input name="Credit" id="Credit" type="text" class="typeTextReadOnly" verification="double" maxlength="4" value="" />
								</div>
								
								<hr/>
							
								<div class="lable">
									<input class="button1" type="submit" value="设置为辅修课程" />
									<input id="formReset" class="button2" type="reset" value="返回" />
								</div>
								
							</form>
						</div>
						
						<div id="searchResult" class="tabContentBox">
						
							<cfset row = 0 />
							<table id="courseList" class="UIEditable">
								<thead>
									<tr>
										<td width="18"></td>
										<td width="50" >任课单位</td>
										<td>课程</td>
										<td>专业方向</td>
										<td width="24" align="center">学分</td>
										<td width="36" align="center">总学时</td>
										<td width="24" align="center">理论</td>
										<td width="24" align="center">实践</td>
										<td width="24" align="center">上机</td>
										<td width="36" align="center">周学时</td>
									</tr>
								</thead>
								<tbody> 
                                    <cfloop query="rs_courses" >
										<cfset row ++ />
										<tr class="clickRows" rowid="<cfoutput>#rs_courses.shm_id#</cfoutput>">
											<td><span class="index"><cfoutput>#row#</cfoutput></span></td>
											<td><cfoutput>#rs_courses.institute_short#</cfoutput></td>
											<td id="courseName<cfoutput>#rs_courses.shm_id#</cfoutput>"><cfoutput>#rs_courses.course_name#</cfoutput></td>
											<td id="dirName<cfoutput>#rs_courses.shm_id#</cfoutput>"><cfif rs_subject.sbj_id neq rs_courses.sbj_id><cfoutput>#rs_courses.sbj_short#</cfoutput></cfif></td>
											<td id="courseCredit<cfoutput>#rs_courses.shm_id#</cfoutput>"><span class="numeric"><cfoutput>#numberFormat(rs_courses.course_credit, "0.0")#</cfoutput></span></td>
											<td align="right"><span class="numeric"><cfoutput>#rs_courses.period#</cfoutput></span></td>
											<td align="right"><span class="numeric"><cfoutput>#rs_courses.period_theory#</cfoutput></span></td>
											<td align="right"><span class="numeric"><cfoutput>#rs_courses.period_practice#</cfoutput></span></td>
											<td align="right"><span class="numeric"><cfoutput>#rs_courses.period_computer#</cfoutput></span></td>
											<td align="right"><span class="numeric"><cfoutput>#rs_courses.period_week#</cfoutput></span></td>
										</tr>
									</cfloop>
								</tbody>
							</table>
						
							<script language="javascript" type="text/javascript">
								//<![CDATA[
								<!--
								$(document).ready(function() {
								
									$("#courseList tr.clickRows").click(function(){
									
										var schmid = $(this).attr("rowid");
										var cname = $("#courseName" + schmid).text();
										var dname = $("#dirName" + schmid).text();
										var ccredit = $("#courseCredit" + schmid).text();

										/* passArgs to FORM */
									
										$("#SchemaID").val(schmid);
										$("#Credit").val(ccredit);
										$("#CourseName").val(cname);
										
										if ( dname.length ) {
											$("#SubjectName").val(dname);
										}
										else {
											$("#SubjectName").val("-/-");
										}
										
									
										$("#searchProcess").removeClass("hidden_elem");
										$("#searchResult").addClass("hidden_elem");
									
									});
								
									$("#formReset").click(function(){
								
										$("#searchResult").removeClass("hidden_elem");
										$("#searchProcess").addClass("hidden_elem");
								
									});
								
								
								});
								// -->
								//]]>
							</script>
						
						</div>
						
					</div>
				</li>
			</ul>
			
		</cfif>
		
	</cfif>

</div>